$(function () {
    collect_product = function (obj) {
        var product_id = $(obj).attr('product-id');
        var params = {
            'product_id': product_id,
            'status': 'do'
        };
        $.ajax({
            url: "/user/collect",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json"
        }).success(function (resp) {
            alert(resp.errmsg);
            location.reload()
        })
    };

    remove_collect = function (obj) {
        var product_id = $(obj).attr('product-id');
        var params = {
            'product_id': product_id,
            'status': 'undo'
        };
        $.ajax({
            url: "/user/collect",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json"
        }).success(function (resp) {
            if (resp.errno == '0') {
                location.reload()
            } else {
                alert(resp.errmsg)
            }
        })
    }

});